草庐IT

python GUI 与 Swing 相比?

全部标签

java - 如何在 Swing 组件调整大小时出现 "do something"?

我有一个扩展JPanel的类。我覆盖了protectedvoidpaintComponent(Graphicsg)。当面板的尺寸发生变化时,必须重新计算一个变量。我该如何以正确的方式做到这一点? 最佳答案 就像AdamPaynter建议的那样,您也可以在代码中添加一个内部类,如下所示:classResizeListenerextendsComponentAdapter{publicvoidcomponentResized(ComponentEvente){//Recalculatethevariableyoumentioned}}您

java - 与另一个几乎相同的函数相比,是什么导致这个递归函数崩溃?

这个问题在这里已经有了答案:Howdothepostincrement(i++)andpreincrement(++i)operatorsworkinJava?(14个回答)关闭7年前。这会导致堆栈溢出错误。我只需要帮助解释为什么这个崩溃与正确的类似的相比。我已经使用了调试器,但我仍然不清楚。publicstaticvoidmain(String[]args){countForwards(5);}publicstaticvoidcountForwards(intnum){if(num>=0){countForwards(num--);}System.out.print(num+"");

java - 与另一个几乎相同的函数相比,是什么导致这个递归函数崩溃?

这个问题在这里已经有了答案:Howdothepostincrement(i++)andpreincrement(++i)operatorsworkinJava?(14个回答)关闭7年前。这会导致堆栈溢出错误。我只需要帮助解释为什么这个崩溃与正确的类似的相比。我已经使用了调试器,但我仍然不清楚。publicstaticvoidmain(String[]args){countForwards(5);}publicstaticvoidcountForwards(intnum){if(num>=0){countForwards(num--);}System.out.print(num+"");

java - 我可以让 Swing JButton 的边距更小吗?

我更喜欢具有最小边距的按钮,大约与它们的文本标题一样宽。有没有办法在Swing中的JButton中实现这一点?我现在在实践中看到的是,即使我尝试使用setMaximumSize()和类似方法,它最终也会吃掉文本标题,将其切断到右侧。但它不会减少利润。 最佳答案 我相信setMargin就是你要找的。myButton.setMargin(newInsets(0,0,0,0)); 关于java-我可以让SwingJButton的边距更小吗?,我们在StackOverflow上找到一个类似的问

java - 我可以让 Swing JButton 的边距更小吗?

我更喜欢具有最小边距的按钮,大约与它们的文本标题一样宽。有没有办法在Swing中的JButton中实现这一点?我现在在实践中看到的是,即使我尝试使用setMaximumSize()和类似方法,它最终也会吃掉文本标题,将其切断到右侧。但它不会减少利润。 最佳答案 我相信setMargin就是你要找的。myButton.setMargin(newInsets(0,0,0,0)); 关于java-我可以让SwingJButton的边距更小吗?,我们在StackOverflow上找到一个类似的问

java - 检测 Java Swing 组件是否被隐藏

假设我们有以下Swing应用程序:finalJFrameframe=newJFrame();finalJPanelouter=newJPanel();frame.add(outer);JComponentinner=newSomeSpecialComponent();outer.add(inner);所以在这个例子中,我们只是在框架中有一个外部面板,在面板中有一个特殊组件。这个特殊的组件在隐藏和显示时必须做一些事情。但问题是setVisible()是在外部面板上调用的,而不是在特殊组件上。所以我不能覆盖特殊组件中的setVisible方法,也不能在它上面使用组件监听器。我可以在父组件上

java - 检测 Java Swing 组件是否被隐藏

假设我们有以下Swing应用程序:finalJFrameframe=newJFrame();finalJPanelouter=newJPanel();frame.add(outer);JComponentinner=newSomeSpecialComponent();outer.add(inner);所以在这个例子中,我们只是在框架中有一个外部面板,在面板中有一个特殊组件。这个特殊的组件在隐藏和显示时必须做一些事情。但问题是setVisible()是在外部面板上调用的,而不是在特殊组件上。所以我不能覆盖特殊组件中的setVisible方法,也不能在它上面使用组件监听器。我可以在父组件上

java - 如何使用 Swing 应用程序配置 spring-boot

我想使用spring-boot-starter-data-jpa功能来创建非Web应用程序。在52.4文档中说:ApplicationcodethatyouwanttorunasyourbusinesslogiccanbeimplementedasaCommandLineRunneranddroppedintothecontextasa@Beandefinition.我的AppPrincipalFrame看起来像:@ComponentpublicclassAppPrincipalFrameextendsJFrameimplementsCommandLineRunner{privateJ

java - 如何使用 Swing 应用程序配置 spring-boot

我想使用spring-boot-starter-data-jpa功能来创建非Web应用程序。在52.4文档中说:ApplicationcodethatyouwanttorunasyourbusinesslogiccanbeimplementedasaCommandLineRunneranddroppedintothecontextasa@Beandefinition.我的AppPrincipalFrame看起来像:@ComponentpublicclassAppPrincipalFrameextendsJFrameimplementsCommandLineRunner{privateJ

java - 如何防止 Java Swing BoxLayout 中的 JTextFields 扩展?

我有一个JPanel,看起来像这样:JPanelpanel=newJPanel();panel.setLayout(newBoxLayout(panel,BoxLayout.Y_AXIS));...panel.add(jTextField1);panel.add(Box.createVerticalStrut(10));panel.add(jButton1);panel.add(Box.createVerticalStrut(30));panel.add(jTextField2);panel.add(Box.createVerticalStrut(10));panel.add(jBut